home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_duke / mapprt.zip / MAP.H < prev    next >
C/C++ Source or Header  |  1996-06-16  |  8KB  |  207 lines

  1. /*
  2.  
  3.    MAP.H
  4.  
  5.    Oliver Kraus
  6.    kraus@lrs.e-technik.uni-erlangen.de
  7.  
  8. */
  9.  
  10.  
  11. #ifndef _MAP_H
  12. #define _MAP_H
  13.  
  14. #include <stdio.h>
  15.  
  16. struct _map_player_struct
  17. {
  18.    long x;
  19.    long y;
  20.    long z;           /* Note: Z coordinates are all shifted up 4 */
  21.    short ang;        /* All angles are from 0-2047, clockwise */
  22.    short secnum;     /* Sector of starting point */
  23. };
  24. typedef struct _map_player_struct map_player_struct;
  25. typedef struct _map_player_struct *map_player_type;
  26.  
  27. struct _map_sector_struct
  28. {
  29.    short wallptr;             /* index to first wall of sector */
  30.    short wallnum;             /* number of walls in sector */
  31.    long ceilingz;             /* z coordinate (height) of ceiling */
  32.    long floorz;               /* floor at first point of sector */
  33.    /*
  34.    bit 0: 1 = parallaxing, 0 = not                                 "P"
  35.    bit 1: 1 = sloped, 0 = not
  36.    bit 2: 1 = swap x&y, 0 = not                                    "F"
  37.    bit 3: 1 = double smooshiness                                   "E"
  38.    bit 4: 1 = x-flip                                               "F"
  39.    bit 5: 1 = y-flip                                               "F"
  40.    bit 6: 1 = Align texture to first wall of sector                "R"
  41.    bits 7-15: reserved
  42.    */
  43.    short ceilingstat;
  44.    short floorstat;
  45.  
  46.    short ceilingpicnum;       /* texture index into art file */
  47.    short ceilingheinum;       /* slope value (rise/run) (0-parallel to floor, 4096-45 degrees) */
  48.  
  49.    signed char ceilingshade;  /* shade offset of ceiling/floor */
  50.    char ceilingpal;           /* palette lookup table number (0 - use std colors) */
  51.    char ceilingxpanning;      /* used to align textures or to do texture panning */
  52.    char ceilingypanning;      /* used to align textures or to do texture panning */
  53.    short floorpicnum;         /* texture index into art file */
  54.    short floorheinum;         /* slope value (rise/run) (0-parallel to floor, 4096-45 degrees) */
  55.    signed char floorshade;    /* shade offset of ceiling/floor */
  56.    char floorpal;             /* palette lookup table number (0 - use std colors) */
  57.    char floorxpanning;        /* used to align textures or to do texture panning */
  58.    char floorypanning;        /* used to align textures or to do texture panning */
  59.    char visibility;           /* determines how fast an area changes shade relative to distance */
  60.    char filler;               /* useless byte to make structure aligned */
  61.    short lotag;
  62.    short hitag;
  63.    short extra;
  64. };
  65. typedef struct _map_sector_struct map_sector_struct;
  66. typedef struct _map_sector_struct *map_sector_type;
  67.  
  68. struct _map_wall_struct
  69. {
  70.    long x;            /* Coordinate of left side of wall, get right */
  71.    long y;            /* side from next wall's left side            */
  72.    short point2;      /* Index to next wall on the right (always in the same sector) */
  73.    short nextwall;    /* Index to wall on other side of wall (-1 if there is no sector) */
  74.    short nextsector;  /* Index to sector on other side of wall (-1 if there is no sector) */
  75.    /*
  76.       bit 0: 1 = Blocking wall (use with clipmove, getzrange)         "B"
  77.       bit 1: 1 = bottoms of invisible walls swapped, 0 = not          "2"
  78.       bit 2: 1 = align picture on bottom (for doors), 0 = top         "O"
  79.       bit 3: 1 = x-flipped, 0 = normal                                "F"
  80.       bit 4: 1 = masking wall, 0 = not                                "M"
  81.       bit 5: 1 = 1-way wall, 0 = not                                  "1"
  82.       bit 6: 1 = Blocking wall (use with hitscan / cliptype 1)        "H"
  83.       bit 7: 1 = Transluscence, 0 = not                               "T"
  84.       bit 8: 1 = y-flipped, 0 = normal                                "F"
  85.       bit 9: 1 = Transluscence reversing, 0 = normal                  "T"
  86.       bits 10-15: reserved
  87.    */
  88.    short cstat;
  89.    short picnum;        /* texture index into art file */
  90.    short overpicnum;    /* texture index into art file for masked walls / 1-way walls */
  91.    signed char shade;   /* shade offset of wall */
  92.    char pal;            /* palette lookup table number (0 - use standard colors) */
  93.    char xrepeat;        /* used to change the size of pixels (stretch textures) */
  94.    char yrepeat;        /* used to change the size of pixels (stretch textures) */
  95.    char xpanning;       /* used to align textures or to do texture panning */
  96.    char ypanning;       /* used to align textures or to do texture panning */
  97.    short lotag;
  98.    short hitag;
  99.    short extra;
  100. };
  101. typedef struct _map_wall_struct map_wall_struct;
  102. typedef struct _map_wall_struct *map_wall_type;
  103.  
  104. struct _map_sprite_struct
  105. {
  106.    long x;                 /* position of sprite - can be defined */
  107.    long y;                 /* at center bottom or center          */
  108.    long z;
  109.    /*
  110.       bit 0: 1 = Blocking sprite (use with clipmove, getzrange)       "B"
  111.       bit 1: 1 = transluscence, 0 = normal                            "T"
  112.       bit 2: 1 = x-flipped, 0 = normal                                "F"
  113.       bit 3: 1 = y-flipped, 0 = normal                                "F"
  114.       bits 5-4: 00 = FACE sprite (default)                            "R"
  115.                 01 = WALL sprite (like masked walls)
  116.                 10 = FLOOR sprite (parallel to ceilings&floors)
  117.       bit 6: 1 = 1-sided sprite, 0 = normal                           "1"
  118.       bit 7: 1 = Real centered centering, 0 = foot center             "C"
  119.       bit 8: 1 = Blocking sprite (use with hitscan / cliptype 1)      "H"
  120.       bit 9: 1 = Transluscence reversing, 0 = normal                  "T"
  121.       bits 10-14: reserved       (ok: seems to be always zero)
  122.       bit 15: 1 = Invisible sprite, 0 = not invisible
  123.    */
  124.    short cstat;
  125.    short picnum;           /* texture index into art file */
  126.    signed char shade;      /* shade offset of sprite */
  127.    char pal;               /* palette lookup table number (0 - use standard colors) */
  128.    char clipdist;          /* the size of the movement clipping square (face sprites only) */
  129.    char filler;            /* useless byte to make structure aligned */
  130.    unsigned char xrepeat;  /* used to change the size of pixels (stretch textures) */
  131.    unsigned char yrepeat;
  132.    signed char xoffset;    /* used to center the animation of sprites */
  133.    signed char yoffset;
  134.    short sectnum;          /* current sector of sprite */
  135.    short statnum;          /* current status of sprite (inactive/monster/bullet, etc.) */
  136.    short ang;              /* angle the sprite is facing */
  137.    short owner;
  138.    short xvel;
  139.    short yvel;
  140.    short zvel;
  141.    short lotag;
  142.    short hitag;
  143.    short extra;
  144. };
  145. typedef struct _map_sprite_struct map_sprite_struct;
  146. typedef struct _map_sprite_struct *map_sprite_type;
  147.  
  148.  
  149. struct _map_struct
  150. {
  151.    char *fname;
  152.    FILE *fp;
  153.    int is_close_fp;
  154.  
  155.    long version;                 /* should be 7 */
  156.  
  157.    map_player_struct player;
  158.  
  159.    short sec_cnt;
  160.    map_sector_struct *sec_list;
  161.  
  162.    short wall_cnt;
  163.    map_wall_struct *wall_list;
  164.  
  165.    short sprite_cnt;
  166.    map_sprite_struct *sprite_list;
  167.  
  168.    long min_x;
  169.    long min_y;
  170.    long max_x;
  171.    long max_y;
  172.  
  173.    int legend_item_cnt;
  174.  
  175.    int  is_monster;
  176.    int  is_card;
  177. };
  178. typedef struct _map_struct map_struct;
  179. typedef struct _map_struct *map_type;
  180.  
  181. #define map_SetMonster(map) ((map)->is_monster = 1)
  182. #define map_ClrMonster(map) ((map)->is_monster = 0)
  183. #define map_SetCard(map) ((map)->is_card = 1)
  184. #define map_ClrCard(map) ((map)->is_card = 0)
  185.  
  186. #define MAP_TYP_MONSTER 1
  187. #define MAP_TYP_CARD    2
  188. #define MAP_TYP_EXIT    3
  189.  
  190. char *map_get_item_id(int idx);
  191. char *map_get_item_string(int idx);
  192. int map_get_item_typ(int idx);
  193. int map_get_item_cnt(int idx);
  194. int map_get_info_idx(short picnum, short palette);
  195.  
  196. int is_map_file(char *name);
  197. int map_name_compare(char *n1, char *n2);
  198.  
  199. map_type map_Open(char *fname, FILE *fp);
  200. void map_Close(map_type map);
  201. int map_Read(map_type map, long pos);
  202. int map_CalculateSize(map_type map);
  203.  
  204. int map_cnt_sprites(map_type map);
  205.  
  206. #endif
  207.